package com.libbase.kotlin.viewmodel

import com.base.kotlin.mvvm.BaseLiveData
import com.base.kotlin.mvvm.BaseViewModel
import com.libbase.bean.NyqfBean
import com.libbase.kotlin.presenter.NyqfContract
import com.libbase.kotlin.NyqfModel
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers

class NyqfViewModel : BaseViewModel<NyqfContract.Model>() {

    val liveData = BaseLiveData<List<NyqfBean.NavBean>>()

    override fun getModel(): NyqfContract.Model {
        return NyqfModel()
    }

    fun getTitles(): Disposable? {
        return mModel?.getTitles()?.subscribeOn(Schedulers.io())
                ?.observeOn(AndroidSchedulers.mainThread())?.subscribe(
                        { result ->
                            liveData.postValue(result.data.nav)
                        }, {
                    liveData.postValue(mutableListOf())
                })
    }
}